﻿using HongXiang.Windows.Forms;
using HuaWei.CommComp;
using HuaWei.Windows.Forms;
using System;
using System.Windows.Forms;

internal static class Program
{
    [STAThread]
    private static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        frmFlash form = new frmFlash();
        try
        {
            form.Show();
            form.Update();
            if (!smethod(form))
            {
                Environment.Exit(Environment.ExitCode);
            }
            else
            {
                FrmLogin login = new FrmLogin();
                form.Close();
                if (login.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    login.Close();
                    FrmMain main = new FrmMain();
                    main.IniLogin();
                    main.Show();
                    Application.Run();
                }
                else
                {
                    Environment.Exit(Environment.ExitCode);
                }
            }
        }
        catch (Exception exception)
        {
            MsgBox.ShowError(exception);
        }
        finally
        {
            form.Close();
        }
    }

    private static bool smethod(Form form)
    {
        FrmKHXX mkhxx = new FrmKHXX();
        int num = mkhxx.CheckRegInfo(form);
        if (num.Equals(0))
        {
            return true;
        }
        if (num.Equals(-1))
        {
            return false;
        }
        return ((num.Equals(1) || num.Equals(2)) && (mkhxx.ShowDialog() == System.Windows.Forms.DialogResult.OK));
    }
}

